-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Woo POS] Coupons: Creation (with dummy entry point UI) #15467
Conversation
Display two existing views to emulate the IPP behavior: - Display discount type selector via BottomSheetListSelector - Display coupon creation view via AddEditCoupon
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works great! 🚢
For a separate PR (maybe not needed): I happened to have coupons disabled from Woo Settings when I was initially testing this:
⛔️ Error creating the coupon: Sorry, there was an issue with the server. Please try again later. (Error code: 403). Response: {"code":"woocommerce_rest_cannot_create","message":"Sorry, you are not allowed to create resources.","data":{"status":403}}
🔵 Tracked coupon_creation_failed, properties: [error_description: Sorry, there was an issue with the server. Please try again later. (Error code: 403). Response: {"code":"woocommerce_rest_cannot_create","message":"Sorry, you are not allowed to create resources.","data":{"status":403}}, blog_id: -1, error_domain: Networking.NetworkError, plan: , store_id: c5bd46cc-1804-4f7b-badb-bb98c449127f, error_code: 2, site_url: https://indiemelon.mystagingwebsite.com, is_wpcom_store: false, was_ecommerce_trial: false]
This happens after selecting the coupon type and filling all the info in the last step before creating it, which might be annoying, perhaps we want to add a call to check the coupon settings when we first tap on "+" and show some toast notification to enable coupons.
That said maybe nothing is necessary since we do this call as soon as we switch to the coupons tab and present an error screen, we just have to remember to disable the button or hide it on that case 👍
@@ -6,7 +6,7 @@ final class AddEditCouponHostingController: UIHostingController<AddEditCoupon> { | |||
|
|||
private let viewModel: AddEditCouponViewModel | |||
|
|||
init(viewModel: AddEditCouponViewModel, onDisappear: @escaping () -> Void) { | |||
init(viewModel: AddEditCouponViewModel, onDisappear: @escaping (_ success: Bool) -> Void) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The success
parameter makes sense in the context of this PR, but if I saw it out of the blue it might be tricky to understand what's the success referring to, like "success of disappear"? Would it make sense to rename the param to something like isCouponCreationSuccess
, couponCreateResultCallback
, or similar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. If question like this comes up, then it definetely makes sense to clarify it 👍
I agree. I added that to the project requirements pdfdoF-6BG-p2 |
Description
On POS, show existing IPP Coupon creation via a dummy entry point UI.
The main goal was to reuse two existing views:
AddEditCoupon
BottomSheetListSelectorViewController
I emulated the flow from the IPP flow:
Show
BottomSheetListSelectorViewController
for selecting coupon type (percentage / fixed) and then showAddEditCoupon
for configuring the view.I created
POSCouponCreationSheet
to encapsulate all the logic. The main complexity was around all the completion handlers so the modal dismissing and navigation would work properly on POS withSwiftUI
.The most notable change was to only refresh the view when the coupon success view is dismissed, not when the coupon code is successfully created to avoid issues that happen when the list is refreshed and the sheet still presented.
Steps to reproduce
Prerequisites: Enable
enableCouponsInPointOfSale
feature flagTesting information
Tested on both iOS 18 and iOS 17 to confirm that modal presentation works correctly. Put focus on testing as many dismissal, coming back and success combinations as possible.
Screenshots
new_coupon_flow.mp4
RELEASE-NOTES.txt
if necessary.Reviewer (or Author, in the case of optional code reviews):
Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement: